package com.qf.fmall.controller;

import com.qf.fmall.entity.Category;
import com.qf.fmall.entity.CategoryVo;
import com.qf.fmall.entity.IndexImg;
import com.qf.fmall.entity.Product;
import com.qf.fmall.service.CategoryService;
import com.qf.fmall.service.ProductService;
import com.qf.fmall.vo.ResultVo;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.sql.ResultSet;
import java.util.List;

/**
 * @author 王权富贵
 */
@Api(value = "提供主页面展示", tags = "主页面商品展示")
@RestController
@RequestMapping(value = "/index")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @Autowired
    private ProductService productService;


    @CrossOrigin
    @RequestMapping(value = "/category-list", method = RequestMethod.GET)
    @ApiOperation(value = "分类列表")
    public List<CategoryVo> listCategory() {
        List<CategoryVo> list = categoryService.getCategoryName();
        return list;
    }

    @ApiOperation(value = "轮播图")
    @CrossOrigin
    @RequestMapping(value = "/indeximg", method = RequestMethod.GET)
    public List<IndexImg> indeximg() {
        List<IndexImg> list = categoryService.getImgList();
        return list;
    }

    @ApiOperation(value = "新品推荐")
    @CrossOrigin
    @RequestMapping(value = "/list-recommends", method = RequestMethod.GET)
    public ResultVo listProduct() {
        ResultVo resultVo = productService.listRecommends();
        return resultVo;
    }

    @ApiOperation(value = "分类商品")
    @CrossOrigin
    @RequestMapping(value = "/category-recommends", method = RequestMethod.GET)
    public ResultVo categoryrecommends() {
        ResultVo resultVo = categoryService.categoryrecommends();
        return resultVo;
    }
}
